package com.example.sale.Mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.sale.True.Birthday;
import com.example.sale.True.User;
import com.example.sale.True.UserDetail;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface UserDetailMapper extends BaseMapper<UserDetail> {
    @Select("SELECT * FROM userdetail WHERE userid = #{userid}")
    UserDetail findBykeyid(@Param("userid") Integer userid);
    @Select("SELECT img FROM userdetail WHERE userid = #{userid}")
    String findPhoto(@Param("userid") Integer userid);
    @Select("SELECT name FROM userdetail WHERE userid = #{userid}")
    String findName (@Param("userid") Integer userid);
    @Select("SELECT count(*) from userdetail where age >= #{age}")
    String findAgeMore(@Param("age") Integer age);
    @Select("SELECT count(*) from userdetail where age < #{age}")
    String findAgeLess(@Param("age") Integer age);
    @Select("SELECT count(*) from userdetail where gender = #{gender}")
    String findGenderNumber(@Param("gender") String gender);

    @Select("SELECT SUBSTRING(birthday, 6, 2) AS month, COUNT(*) AS count " +
            "FROM userdetail " +
            "WHERE SUBSTRING(birthday, 6, 2) = #{month} " +
            "GROUP BY SUBSTRING(birthday, 6, 2) " +
            "ORDER BY SUBSTRING(birthday, 6, 2)")
    List<Birthday> getBirthDayNumber(@Param("month") String month);
    @Select("SELECT qq FROM userdetail WHERE userid = (SELECT id FROM user WHERE username = #{username})")
    String getQQNumber(@Param("username") String username);
    @Select("select password from user where username =#{username}")
    String getPassword(@Param("username") String username);
}
